﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

namespace BLL.Admin
{
    public class DMNhomKiNangHelper
    {
        public static void AddNhomKiNang(string tenNhomKiNang)
        {
            var db = Connect.GetDataContext<TimViecDataContext>("Strconnect");
            tbl_DM_NhomKiNang nhomKiNang = new tbl_DM_NhomKiNang();
            nhomKiNang.TenNhomKiNang = tenNhomKiNang;
            db.tbl_DM_NhomKiNangs.InsertOnSubmit(nhomKiNang);
            db.SubmitChanges();
        }
        public static void UpdateNhomKiNang(int Id, string tenNhomKiNang)
        {
            var db = Connect.GetDataContext<TimViecDataContext>("Strconnect");
            tbl_DM_NhomKiNang nhomKiNang = db.tbl_DM_NhomKiNangs.FirstOrDefault(k => k.NhomKiNangId == Id);
            nhomKiNang.TenNhomKiNang = tenNhomKiNang;
            db.SubmitChanges();
        }

        public static IQueryable ListNhomKiNang()
        {
            var db = Connect.GetDataContext<TimViecDataContext>("Strconnect");
            var query = from qg in db.tbl_DM_NhomKiNangs
                        orderby qg.TenNhomKiNang ascending
                        select new
                        {
                            qg.TenNhomKiNang,
                            qg.NhomKiNangId
                        };
            return query;
        }
    }
}